Callable Service is similar to Service in being a generic container for user-defined modeling of a process that executes on the server tier, but while Service is called by other processes in the application by being included in their models, Callable Service is called via a URL (from the same application or from another application).
Callable Service returns either a file or data.
Callable Service
is “called” by referring to the service’s
URL (e.g. by typing the service’s URL in your browser).
When the browser (or an HTTP request) is accessing the service, the
service retrieves its parameters from the URL and starts executing.
When it finishes, it returns its output.
The syntax of the service’s URL differentiates between the
various output types (file or data) and usage modes (calling from
within a Tersus Application [using a relative URL] vs. calling from
another application [using a fully formed URL]). The details are
explained below.
Called: | By a Tersus application. |
Returns: | An image file to display. |
Service Modeling: | Model a Callable Service that reads the required image from the database and returns it as a File data structure. |
Usage: | In the calling application, use an Image display element and set its <Path> element to the URL of the Callable Service. At runtime, whenever the Image element should be displayed, the Callable Service is invoked to obtain the image file. |
Try it online: | Go to the File Library perspective in the Examples project, upload an image file to the library, and if you mark it as “Is Image”, you’ll see it displayed in the file list. |
Called: | By a Tersus application. |
Returns: | A graph as an image file to display. |
Service Modeling: | Model a Callable Service that uses any of the templates in the Charts category of the palette (for instance Generate Line Chart) to generate a graph image and return it as a File data structure. |
Usage: | In the calling application, use an Image display element and set its <Path> element to the URL of the Callable Service. At runtime, whenever the Image element should be displayed, the Callable Service is invoked to generate the graph’s file. |
Try it online: | Go to the Web Services - Forex perspective in the Examples project, select a currency and press the Show Graph button. |
Called: | By any application (or simply the browser). |
Returns: | A file for download. |
Service Modeling: | Same as in use case 1 - the browser uses the same download mechanism for images it needs to display, as it does for any other file type. |
Usage: | You want to provide the ability to access files stored in a database to any applications capable of performing an HTTP request (the browser is one such application). Use the callable service implemented for use case 1. |
Try it online: | To open the Welcome to Tersus Studio page stored in the database of the Examples application, enter the following URL in your browser (or click it): http://applications.tersus.com/Examples/File/?_path=File%20Library%2FDownload&Id=1. |
Called: | By any application (or simply the browser). |
Returns: | A file for download. |
Service Modeling: | Same as in use cases 1 or 2, depending on the image source. |
Usage: | You want to provide access to the images discussed in use cases 1 and 2 to any application capable of performing an HTTP request (such as the browser itself). You can do so by making use of the same callable services. |
Try it online: | Enter the
following URLs in your browser (or click it), to see the images: Use case 4.1 – Image from database: http://applications.tersus.com/Examples/File/?_path=File%20Library%2FDownload&Id=2 Use case 4.2 – Generated graph: http://applications.tersus.com/Examples/File/?_path=Web%20Services%2FWeb%20Services%20-%20Forex%2FGenerate%20Rates%20Graph&Curr1=EUR&Curr2=GBP |
Called: | By an external application. |
Returns: | Several counters on the current status of a Tersus application. |
Service Modeling: | A Tersus CRM application exposes counters (daily number of cases, resolution rate, etc.) through a callable service. It is modeled to receive the Date for which statistics are requested, and returns them. |
Usage: | An external application (e.g. a reporting tool) can
access the Tersus
application at any time to display the most up-to-date statistics. The
external
application will issue an HTTP request with a URL similar to the
following: http://applications.tersus.com/Examples/Service/?_path=Data%20Service&Date=2008-02-29 Assuming the service has two numeric exits “Cases” and “Resolved Cases”, then the service returns the string ‘{"Cases":\n157\n,“Resolved Cases”:\n134\n} ’. If the external application is implemented using Tersus, you can use Miscellaneous/HTTP Post to perform the request, and Miscellaneous/Parse JSON to parse the result. |
Try it online: | Go to the Callable Service view of the Tests
perspective in the Examples
project, and select a date to see the statistics for that date. |